package com.asa.voice.mp3.asa.decoder;


public final class SynthesisConcurrent implements Runnable {
  private int ch;
  
  private float[] samples;
  
  private float[][] preXR;
  
  private float[][] curXR;
  
  private Layer3 owner;
  
  private boolean pause;
  
  private boolean alive;
  
  public SynthesisConcurrent(Layer3 paramLayer3, int paramInt) {
    this.owner = paramLayer3;
    this.ch = paramInt;
    this.alive = this.pause = true;
    this.samples = new float[32];
    this.preXR = new float[paramLayer3.granules][576];
    this.curXR = new float[paramLayer3.granules][576];
  }
  
  public float[][] startSynthesis() {
    float[][] arrayOfFloat = this.preXR;
    this.preXR = this.curXR;
    this.curXR = arrayOfFloat;
    synchronized (this) {
      this.pause = false;
      notify();
    } 
    return this.preXR;
  }
  
  public float[][] getBuffer() {
    return this.preXR;
  }
  
  public synchronized void shutdown() {
    this.alive = this.pause = false;
    notify();
  }
  
  public void run() {
    int i = this.owner.granules;
    Synthesis synthesis = this.owner.filter;
    try {
      while (this.alive) {
        synchronized (this) {
          while (this.pause)
            wait(); 
          this.pause = true;
        } 
        for (byte b = 0; b < i; b++) {
          float[] arrayOfFloat = this.curXR[b];
          for (byte b1 = 0; b1 < 18; b1 += 2) {
            byte b2;
            int j;
            for (j = b1, b2 = 0; b2 < 32; b2++, j += 18)
              this.samples[b2] = arrayOfFloat[j]; 
            synthesis.synthesisSubBand(this.samples, this.ch);
            for (j = b1 + 1, b2 = 0; b2 < 32; b2 += 2, j += 36) {
              this.samples[b2] = arrayOfFloat[j];
              this.samples[b2 + 1] = -arrayOfFloat[j + 18];
            } 
            synthesis.synthesisSubBand(this.samples, this.ch);
          } 
        } 
        this.owner.submitSynthesis();
      } 
    } catch (InterruptedException interruptedException) {}
  }
}

